package com.apes.pi.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 发送方
 * 发起调用请求方
 * @author wuq
 * @create 2019-10-19 10:11
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = Sender.CONST_TABLE_NAME)
public class Sender extends Model {
    public static final String CONST_TABLE_NAME = "pi_Sender";

    @Id
    @Column(name = "id", nullable = false, length = 8)
    @Comment("发送方编码")
    private String id; // appKey

    @Column(name = "secret", nullable = false, length = 120)
    @Comment("发送方秘钥")
    private String secret;

    //  发送者描述
    @Column(name = "name", nullable = false, length = 120)
    @Comment("发送方描述")
    private String name;

    // 参数列表
    @OneToMany(mappedBy = "sender", cascade=CascadeType.ALL, orphanRemoval = true)
    private List<SenderParams> params;

}
